//
//  FavoriteViewController.m
//  Work
//
//  Created by Apple on 15/12/15.
//  Copyright © 2015年 mohekeji. All rights reserved.
//

#import "FavoriteViewController.h"
#import "FavoriteTableViewCell.h"
#import "DenLuViewController.h"
#import "PageView.h"
@interface FavoriteViewController ()<UIImagePickerControllerDelegate,PageViewDelegate>
{
    NSArray * imageArray;
    NSArray * dataSource;
}
@end

@implementation FavoriteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _array = @[
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"},
               @{@"title":@"康拜因",@"content":@"云南丽江大石桥镇123号",@"imageView":@"农机"}];
    //设置箭头不带文字
    UIBarButtonItem * barButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    //修改箭头的颜色
    [self.navigationController.navigationBar setTintColor:[UIColor redColor]];
    //自定义导航栏的颜色
    [self.navigationController.navigationBar setBarTintColor:[UIColor orangeColor]];
    [self.tableVIew registerNib:[UINib nibWithNibName:@"FavoriteTableViewCell" bundle:nil] forCellReuseIdentifier:@"ReusefulCell"];
    self.backView.backgroundColor = [UIColor redColor];
    imageArray = @[@"厂家",@"名称",@"厂家"];
    PageView * pageView = [[PageView alloc]initPageViewFrame:CGRectMake(0, 0, 320, 150)];
    pageView.backgroundColor = [UIColor yellowColor];
    pageView.duration = 1.0;
    pageView.imageArray = imageArray;
    pageView.delegate = self;
    pageView.isWebImage = NO;
    [self.backView addSubview:pageView];
    // Do any additional setup after loading the view from its nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    FavoriteTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ReusefulCell" forIndexPath:indexPath];
//    FavoriteTableViewCell * cell = [[[NSBundle mainBundle]loadNibNamed:@"FavoriteTableViewCell" owner:self options:nil]lastObject];
    NSDictionary * dic = [_array objectAtIndex:indexPath.row];
    cell.label.text = dic[@"title"];
    cell.image.image = [UIImage imageNamed:dic[@"imageView"]];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row ==0) {
        DenLuViewController * vc = [[DenLuViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row ==1) {
        DenLuViewController * vc = [[DenLuViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)zhongZi:(id)sender {
    UIAlertController * vc = [UIAlertController alertControllerWithTitle:@"友情提示" message:@"按钮被点击了" preferredStyle:UIAlertControllerStyleAlert];
    [vc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    
    }]];
    [vc addAction:[UIAlertAction actionWithTitle:@"取消" style:0 handler:^(UIAlertAction * _Nonnull action) {
        
    }]];
    //两个按钮同排显示，三个按钮并排显示
//    [vc addAction:[UIAlertAction actionWithTitle:@"分享" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        
//    }]];
    //添加一个UITextField
//    [vc addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
//    }];
     [self presentViewController:vc animated:true completion:nil];
}
- (IBAction)sheetShow:(id)sender {
    UIAlertController * vc = [UIAlertController alertControllerWithTitle:@"提示" message:@"点击了按钮" preferredStyle:0];
    [vc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }]];
    [vc addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }]];
    [vc addAction:[UIAlertAction actionWithTitle:@"分享" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }]];

    [self presentViewController:vc animated:true completion:^{
        
    }];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
